class PhieuSachesController < ApplicationController
  # GET /phieu_saches
  # GET /phieu_saches.json
  def index
	@phieu_saches = PhieuSach.search(params[:search])
  end

  # GET /phieu_saches/1
  # GET /phieu_saches/1.json
  def show
    @phieu_sach = PhieuSach.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @phieu_sach }
    end
  end

  # GET /phieu_saches/new
  # GET /phieu_saches/new.json

  def new
    @phieu_sach = PhieuSach.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @phieu_sach }
    end
  end

  # GET /phieu_saches/1/edit
  def edit
    @phieu_sach = PhieuSach.find(params[:id])
  end

  # POST /phieu_saches
  # POST /phieu_saches.json
  def create
    @phieu_sach = PhieuSach.new(params[:phieu_sach])

    respond_to do |format|
      if @phieu_sach.save
        format.html { redirect_to @phieu_sach, notice: 'Phieu sach was successfully created.' }
        format.json { render json: @phieu_sach, status: :created, location: @phieu_sach }
      else
        format.html { render action: "New" }
        format.json { render json: @phieu_sach.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /phieu_saches/1
  # PUT /phieu_saches/1.json
  def update
    @phieu_sach = PhieuSach.find(params[:id])

    respond_to do |format|
      if @phieu_sach.update_attributes(params[:phieu_sach])
        format.html { redirect_to @phieu_sach, notice: 'Phieu sach was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @phieu_sach.errors, status: :unprocessable_entity }
      end
    end
  end
  
   

  # DELETE /phieu_saches/1
  # DELETE /phieu_saches/1.json
  def destroy
    @phieu_sach = PhieuSach.find(params[:id])
    @phieu_sach.destroy

    respond_to do |format|
      format.html { redirect_to phieu_saches_url }
      format.json { head :no_content }
    end
  end
  
def search
   @phieu_sach = PhieuSach.find(params[:id])
   respond_to do |format|
         format.html { render action: "search" }
        format.json { render json: @phieu_sach.errors, status: :unprocessable_entity }
		end
  #@phieu_sach = PhieuSach.search params[:search]
end
end
